package com.config.ser.springevent;

import com.config.ser.service.CloudConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 启动后直接从数据库拉取配置，并缓存到本地内存
 */
@Component
public class SpringStartEvent implements ApplicationRunner {

    @Autowired
    private CloudConfigService cloudConfigService;
    /**
     * 拉去所有配置到缓存中
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        cloudConfigService.pullAllConfig();
    }
}
